package com.qfedu.vhr.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author baize
 * @date 2023/2/8
 * @site www.qfedu.com
 */
@Configuration
public class RabbitConfig {

    public static final String EMPLOYEE_MAIL_EXCHANGE_NAME = "employee_mail_exchange_name";
    public static final String EMPLOYEE_MAIL_QUEUE_NAME = "employee_mail_queue_name";

    @Bean
    Queue mailQueue() {
        return new Queue(EMPLOYEE_MAIL_QUEUE_NAME, true, false, false);
    }

    @Bean
    DirectExchange mailExchange() {
        return new DirectExchange(EMPLOYEE_MAIL_EXCHANGE_NAME, true, false);
    }

    @Bean
    Binding mailBinding() {
        return BindingBuilder.bind(mailQueue())
                .to(mailExchange())
                .withQueueName();
    }
}
